//
//  BaseTableViewController.swift
//  WeiBo_One
//
//  Created by apple on 15/10/19.
//  Copyright © 2015年 蜡笔小炎. All rights reserved.
//

import UIKit


class BaseTableViewController: UITableViewController {
    
    /// 登录标志
    var isUserLogon: Bool = UserAccountViewModel.sharedAccoutViewModel.userLogon
    
    /// 访客视图
    var visitorView: VisitorView = VisitorView()
    
    /// 加载视图
    override func loadView() {
        isUserLogon ? super.loadView() : loadVisitorView()
    }
    
    /// 加载游客视图
    func loadVisitorView() {
        view = visitorView
        
        // 注册和登录item注册点击事件
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "registBtnDidClick")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "loginBtnDidClick")
        //访客视图‘注册’和‘登录’注册点击事件
        visitorView.registBtn.addTarget(self, action: "registBtnDidClick", forControlEvents: .TouchUpInside)
        visitorView.loginBtn.addTarget(self, action: "loginBtnDidClick", forControlEvents: .TouchUpInside)
    }
    
    /// 注册按钮点击事件
    func registBtnDidClick() {
        print("点击了注册按钮")
    }
    /// 登录按钮点击事件
    func loginBtnDidClick() {
        
        //modal 出授权界面
        let nav = UINavigationController(rootViewController: OAuthViewController())

        presentViewController(nav, animated: true, completion: nil)
    }

    
}
